import bus from "@/bus";
import { renderButton } from '@/util'
let data = {
  status: 'pass',
  totalItem: 22,
  pageSize: window.$pageSize,
  currentPage: 1,
  form: {
  },
  columns: [{
      type: 'selection',
      width: 60,
      align: 'left',
      fixed: 'left'
    }, {
      title: '姓名',
      key: 'realname',
      minWidth: 150,
      align: 'left',
    }, {
      title: '昵称',
      key: 'nickName',
      align: 'left',
      minWidth: 150
    }, {
      title: '登录账号',
      key: 'mobile',
      align: 'left',
      minWidth: 150
    },
    {
      title: '经销商',
      key: 'distributorName',
      align: 'left',
      minWidth: 200
    }, {
      title: '品牌方',
      key: 'supplierName',
      align: 'left',
      minWidth: 200
    }, {
      title: '品牌',
      key: 'salesmanContractBrandDTOS',
      align: 'left',
      width: 200,
      render: (h, p) => {
        let temp = (p.row.salesmanContractBrandDTOS || []).map(it => it.brandName).join(',')
        return <div class="e1" title={temp}>{temp}</div>
      }
    },
    {
      title: '职能类型',
      key: 'roleName',
      minWidth: 200,
      align: 'left'
    },
    {
      title: '创建时间',
      key: 'createDate',
      minWidth: 200,
      align: 'left',
    },
    {
      title: '审核时间',
      key: 'modifyDate',
      align: 'left',
      minWidth: 200
    },
    {
      title: '审核状态',
      key: 'auditStatus',
      align: 'left',
      minWidth: 150,
      render: (h, p) => {
        let obj = { 0: "待审核" , 1: "审核不通过", 2: "审核通过"}
        return <div>{obj[p.row.auditStatus]}</div>
      }
    },
    {
      title: '是否签约',
      key: 'contractStatus',
      align: 'left',
      minWidth: 100,
      render: (h, p) => {
        return <span>{p.row.contractStatus ? '是':'否'}</span>
      }
    },
    {
      title: '操作',
      align: 'right',
      minWidth: 200,
      render: (h, params) => {
        let edit = renderButton(h, { text: '编辑', type: 'primary', },
          () => { bus.$emit("onEdit", params.row.id) })  
        let check = renderButton(h, { text: '审核', type: 'primary', },
        () => { bus.$emit("onCheck", params.row) })
        let sign = renderButton(h, { text: '签约', type: 'success', },
        () => { bus.$emit("onSign", params.row) })
        let unsign = renderButton(h, { text: '解约', type: 'warning', },
        () => { bus.$emit("onUnsign", params.row) })
        if (params.row.auditStatus === 0) {
          return [edit, check]
        }
        if ((params.row.auditStatus === 1 || params.row.auditStatus === 2) && params.row.contractStatus === 1) {
          return [edit, unsign]
        }
        if ((params.row.auditStatus === 1 || params.row.auditStatus === 2) && params.row.contractStatus === 0) {
          return [edit, sign]
        }
        return [edit]
      }
    }
  ],
  data: []
}
export default data;
